
exports.harvest = function(player, req, resp, onHandled) {
    player.action.score = 20;
    do {
        var user = player.user;

        var levelConf = gConfLevel[user.status.level];
        if( !levelConf ) {
            resp.code = 1; resp.desc = 'level error'; break;
        }

        var now = common.getTime();
        var passed =  now - user.farm.timer;
        if( passed < 10 ) {
            resp.code = 1; resp.desc = 'time error'; break;
        }
        var addFood = Math.floor(passed * (+levelConf.FoodPerHour) / 3600);
        if( addFood > +levelConf.FoodMax ) {
            addFood = +levelConf.FoodMax;
        }

        user.farm.timer = now; 
        user.status.food += addFood;

        player.markDirty('farm.timer');
        player.markDirty('status.food');

        player.doDailyTask(gConfDailyTask.HarvestFarm);
        player.doTask('HarvestFood','all');

        resp.data.food = addFood;
        resp.data.timer = now;
        resp.daily_task = gConfDailyTask.HarvestFarm;
    }while(false);

    onHandled();
}
